/**
 * 
 * @author Nixxx
 * 
 *         This controller finds a ball, and pushes it to an opposite wall
 */

public class BallWallPusher extends Subsumption {

	public BallWallPusher() {
		setWaitTime(5);
		m_cruiserFlag = false;
		m_wcheckerFlag = false;
		m_bfinderFlag = false;
		m_bpusherFlag = false;

		m_milage = 0;
	}


	public void doWork() throws Exception {
		wallChecker();

		if (m_wcheckerFlag == false) {
			ballPusher();

			if (m_bpusherFlag == false) {
				ballFinder();

				if (m_bfinderFlag == false) {
					cruise();
				}

			}

		}

		arbitrate();
		setMilage();
	}


	public void arbitrate() {

		if (m_cruiserFlag == true) {
			System.out.println("Cruise");
			setMotorSpeeds(m_cruiseOutput[0], m_cruiseOutput[1]);
		}
		if (m_bfinderFlag == true) {
			System.out.println("Ballfinder");
			setMotorSpeeds(m_bfinderOutput[0], m_bfinderOutput[1]);
		}
		if (m_bpusherFlag == true) {
			System.out.println("Ballpusher");
			setMotorSpeeds(m_bpusherOutput[0], m_bpusherOutput[1]);
		}
		if (m_wcheckerFlag == true) {
			System.out.println("Avoid");
			setMotorSpeeds(m_wcheckerOutput[0], m_wcheckerOutput[1]);
			this.sleep(1200);
		}
	}

}
